﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace InfoPick.Lib.Entity
{
    public class GSN7LNK
    {
        /// <summary>
        /// Idx，用于排序，找出“系统号”
        /// </summary>
        public int Idx { get; set; }

        /// <summary>
        /// 链路名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// CSU模块号
        /// </summary>
        public int CSUNum { get; set; }

        /// <summary>
        /// E1内部时隙号
        /// </summary>
        public int E1Num { get; set; }

        /// <summary>
        /// E1端口
        /// </summary>
        public int E1Port { get; set; }

        /// <summary>
        /// 链路集名称
        /// </summary>
        public string LinkSetName { get; set; }

        /// <summary>
        /// 信令链路编码
        /// </summary>
        public int DPC { get; set; }

        /// <summary>
        /// 链路类型
        /// </summary>
        public string LinkType { get; set; }

        public static GSN7LNK Create64K(string[] row)
        {
            try
            {
                GSN7LNK obj = new GSN7LNK();
                obj.Name = row[0];
                obj.CSUNum = int.Parse(row[1]);
                obj.E1Num = int.Parse(row[2]);
                obj.E1Port = int.Parse(row[3]);
                obj.LinkSetName = row[4];
                obj.DPC = int.Parse(row[5]);

                obj.LinkType = string.Format("{0} {1}", row[12], row[13]);
                return obj;
            }
            catch (Exception e)
            {
                return null;
            }
        }

        public static GSN7LNK Create2M(string[] row)
        {
            try
            {
                GSN7LNK obj = new GSN7LNK();
                obj.Name = row[0];
                obj.CSUNum = int.Parse(row[1]);
                obj.E1Num = int.Parse(row[2]);
                obj.E1Port = int.Parse(row[3]);
                obj.LinkSetName = row[5];
                obj.DPC = int.Parse(row[6]);

                obj.LinkType = string.Format("{0} {1}", row[13], row[14]);
                return obj;
            }
            catch (Exception e)
            {
                return null;
            }
        }
    }
}
